import request from '@/utils/request'
// import store from '@/store'

export function fetchSystemInfo() {
  return request({
    url: '/v1/opration/system-status/',
    method: 'get'
  })
}

export function fetchFirewallConfig() {
  return request({
    url: '/v1/opration/firewall-status/',
    method: 'get',
  })
}

export function portScan(data) {
  return request({
    url: '/v1/opration/port-scan/',
    method: 'get',
    params: {
      start_port: data.start_port,
      end_port: data.end_port,
      host: data.host
    },
    timeout: data.timeout || 10000 // 设置10秒超时
  })
}

export function getDjangoInfo() {
  return request({
    url: '/v1/opration/django-status/',
    method: 'get'
  })
}

export function getNetworkScan() {
  return request({
    url: '/v1/opration/network-scan/',
    method: 'get',
    timeout: 100000
  })
}

export function executeSSHCommand(data) {
  return request({
    url: '/v1/opration/ssh-command/',
    method: 'post',
    data,
    timeout: 100000
  })
}

export function connectSSH(data) {
  return request({
    url: '/v1/opration/ssh-connect/',
    method: 'post',
    data
  })
}

export function getApiStatistics() {
  return request({
    url: '/v1/opration/api-statistics/',
    method: 'get'
  })
}

// 添加 UFW 端口
export function addUfwPort(data) {
  return request({
    url: '/v1/opration/firewall/add-port/',
    method: 'post',
    data
  })
}

// 删除 UFW 端口
export function deleteUfwPort(data) {
  return request({
    url: '/v1/opration/firewall/delete-port/',
    method: 'post',
    data
  })
}

